package com.gxar.quick.ar.server.base.common.enums;

import java.util.Arrays;
import java.util.Optional;

/**
 * @author linsy
 * @version 1.0
 * @created 2023/11/10 09:53
 */
public enum ComboConfigItemUnitEnum {
    NUMBER(1, "Number", "个"),
    FREQUENCY(2, "Frequency", "次"),
    CAPACITY_KB(3, "KB", "KB"),
    BOOLEAN(4, "Boolean", "布尔"),
    ;

    private final Integer code;
    private final String name;
    private final String desc;

    /**
     * 根据名称查询
     *
     * @param name 名称
     * @return 枚举
     */
    public static ComboConfigItemUnitEnum getByName(String name) {
        Optional<ComboConfigItemUnitEnum> first = Arrays.stream(ComboConfigItemUnitEnum.values()).filter(e -> e.getName().equals(name)).findFirst();
        return first.orElse(null);
    }

    ComboConfigItemUnitEnum(Integer code, String name, String desc) {
        this.code = code;
        this.name = name;
        this.desc = desc;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public String getDesc() {
        return desc;
    }
}
